package main

import (
	"strconv"
	"strings"
)

func compareVersion(version1, version2 string) int {
	vfs1 := strings.Split(version1, ".")
	vfs2 := strings.Split(version2, ".")
	vfsl1 := len(vfs1)
	vfsl2 := len(vfs2)
	if vfsl1 < vfsl2 {
		for i := 0; i < vfsl2-vfsl1; i++ {
			vfs1 = append(vfs1, "0")
		}
	} else if vfsl1 > vfsl2 {
		for i := 0; i < vfsl1-vfsl2; i++ {
			vfs2 = append(vfs2, "0")
		}
	}

	var (
		n1, n2 int
	)
	for index, _ := range vfs1 {
		n1, _ = strconv.Atoi(vfs1[index])
		n2, _ = strconv.Atoi(vfs2[index])
		if n1 < n2 {
			return -1
		} else if n1 > n2 {
			return 1
		}
	}

	return 0
}
